//属性分类接口
import request from '@/utils/request'
import type { CategoryResponseData, AttrResponseData,Attr } from './type'

//一级分类
export const reqCategory1API = () =>
  request.get<any, CategoryResponseData>('/admin/product/getCategory1')

// const category1API=() => {
//     return request<any,any>({
//         url:'/admin/product/getCategory1',
//         method:'get'
//     })
// }
//二级分类
export const reqCategory2API = (category1Id: number | string) =>
  request.get<any, CategoryResponseData>(
    `/admin/product/getCategory2/${category1Id}`
  )

// export const reqCategory2API = (category1Id: number) =>{
//     return request({
//         url:`/admin/product/getCategory2/${category1Id}`,
//         url:'/admin/product/getCategory2/' + category1Id
//         method:'get'
//     })
// }
//三级分类
export const reqCategory3API = (category2Id: number | string) =>
  request.get<any, CategoryResponseData>(
    `/admin/product/getCategory3/${category2Id}`
  )

//获取三级分类商品基础属性
export const reqAtttAPI = (
  category1Id: number | string,
  category2Id: number | string,
  category3Id: number | string
) =>
  request.get<any, AttrResponseData>(
    `/admin/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`
  )

//添加或修改三级分类的属性值接口（有id是修改，没id是添加）
export const reqAddOrUpdateAttrAPI = (data: Attr) =>
  request.post<any, any>('/admin/product/saveAttrInfo', data)

//删除属性接口
export const reqDeleteAttrAPI = (attrId: number) =>
  request.delete<any, any>(`/admin/product/deleteAttr/${attrId}`)
